<clr-datagrid (clrDgRefresh)="refresh($event)">
  <clr-dg-column >
    <ng-container>
      ID
    </ng-container>
  </clr-dg-column>
  <clr-dg-column [clrDgField]="'name'">
    <ng-container *clrDgHideableColumn="showState['名称']">
      名称 
    </ng-container>
  </clr-dg-column>
  <clr-dg-column>
    <ng-container *clrDgHideableColumn="showState['URL']">
      URL
    </ng-container>
  </clr-dg-column>
  <clr-dg-column>
    <ng-container *clrDgHideableColumn="showState['启用状态']">
      启用状态
    </ng-container>
  </clr-dg-column>
  <clr-dg-column [clrDgField]="'user'">
    <ng-container *clrDgHideableColumn="showState['创建用户']">
      创建用户 
    </ng-container>
  </clr-dg-column>
  <clr-dg-column>
    <ng-container *clrDgHideableColumn="showState['创建时间']">
      创建时间
    </ng-container>
  </clr-dg-column>
  <clr-dg-column
      *ngIf="
      authService.currentNamespacePermission.webHook.update ||
      authService.currentAppPermission.webHook.update ||
      authService.currentNamespacePermission.webHook.delete ||
      authService.currentAppPermission.webHook.delete ||
      authService.currentUser.admin"
  >
    <ng-container *clrDgHideableColumn="showState['操作']">
      操作
    </ng-container>
  </clr-dg-column>
  <clr-dg-row *ngFor="let webHook of webHooks; let i = index" [clrDgItem]="webHook">
    <clr-dg-cell>{{webHook.id}}</clr-dg-cell>
    <clr-dg-cell class="copy">{{webHook.name}}</clr-dg-cell>
    <clr-dg-cell>{{webHook.url}}</clr-dg-cell>
    <clr-dg-cell>
			<div class="toggle-switch">
				<input 
          type="checkbox"  
          id="webhook-toggle-{{i}}"
          (change)="toggleWebhook(webHook)"
          [checked]="webHook.enabled"
        >
        <label for="webhook-toggle-{{i}}"></label>
			</div> 
		</clr-dg-cell>
    <clr-dg-cell>{{webHook.user}}</clr-dg-cell>
    <clr-dg-cell>{{webHook.createTime | date:"yyyy-MM-dd HH:mm"}}</clr-dg-cell>
    <clr-dg-cell
      *ngIf="
      authService.currentNamespacePermission.webHook.update ||
      authService.currentAppPermission.webHook.update ||
      authService.currentNamespacePermission.webHook.delete ||
      authService.currentAppPermission.webHook.delete ||
      authService.currentUser.admin"
    >
      <button class="wayne-button text"
      *ngIf="authService.currentNamespacePermission.webHook.update ||
        authService.currentAppPermission.webHook.update ||
        authService.currentUser.admin"
        (click)="editWebhook(webHook)">
        编辑</button>
      <button class="wayne-button text"
        *ngIf="authService.currentNamespacePermission.webHook.delete ||
          authService.currentAppPermission.webHook.delete ||
          authService.currentUser.admin"
        (click)="deleteWebhook(webHook)">
        删除</button>
    </clr-dg-cell>
  </clr-dg-row>

  <wayne-paginate
    [(currentPage)]="currentPage"
    [total]="page.totalCount"
    [pageSizes]="[10, 20, 50]"
    (sizeChange)="pageSizeChange($event)"
  >
  </wayne-paginate>
</clr-datagrid>
